import {homeMethod} from '@/utils/models/index.js'
const crudMethod = new homeMethod();
import Footer from '@/components/footer-main'
export default {
  name: 'Home',
  components: { Footer},
  data() {
    return {
      articleId: null,
      loading: false,
      preview: null,
      articleLoad: false,
      articleData: [],
      articleBg: {
        backgroundImage: require('@/assets/images/companyNewsBg.png'),
        backgroundRepeat: 'no-repeat',
        backgroundPosition: 'center',
        backgroundSize: '100% 100%'
      },
    }
  },
  created() {
    this.articleId = this.$route.query.id
     this.getDetail()
    this.getArticles()
  },
  methods: {
    goDetails(id) {
      this.articleId = id
      this.getDetail()
    },
    getDetail() {
      let _this = this
      _this.loading = true
      crudMethod.getArticleDetail(_this.articleId).then((res) => {
        _this.loading = false
        let {msg, code, data} = res;
        document.title = data.data.articleTitle
        _this.preview = data.data
      })
    },
    // 分页查询公司新闻
    getArticles () {
      let _this = this
      _this.articleLoad = true
      let params = {
        pageNum: 1,
        pageSize: 10
      }
      crudMethod.getArticleFindPage(params).then((res) => {
        _this.articleLoad = false
        let {msg, code, data} = res;
        data.rows.forEach(item => {
          item.articlePic = item.articlePic ? _this.baseURL + item.articlePic : ''
        })
        _this.articleData = data.rows
      })
    },
  }
}
